package com.echo.echovividlive.service.impl;

import com.echo.echovividlive.common.UserThread;
import com.echo.echovividlive.domain.dto.LiveRoomPageDTO;
import com.echo.echovividlive.domain.entity.LiveRecord;
import com.echo.echovividlive.domain.entity.Result;
import com.echo.echovividlive.domain.vo.PageVO;
import com.echo.echovividlive.mapper.LiveRecordMapper;
import com.echo.echovividlive.service.ILiveRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiajunjie
 * @since 2024-11-26
 */
@Service
public class LiveRecordServiceImpl extends ServiceImpl<LiveRecordMapper, LiveRecord> implements ILiveRecordService {

    @Resource
    private LiveRecordMapper liveRecordMapper;

    @Override
    public Result pageList(LiveRoomPageDTO liveRoomPageDTO) {
        PageHelper.startPage(liveRoomPageDTO.getPageIndex(),liveRoomPageDTO.getPageSize()==null?10:liveRoomPageDTO.getPageSize());
        liveRoomPageDTO.setUserId(UserThread.getUserId());
        Page<LiveRecord> pageList = liveRecordMapper.pageList(liveRoomPageDTO);
        return Result.success(new PageVO(pageList.getTotal(),pageList.getResult()));
    }
}
